﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace VK.Casemeet.Web.Admin.Controls
{
    public partial class MapPathControl : System.Web.UI.UserControl
    {
        public List<MapPath> MapPathList { set; get; }

        private const string SiteMapPathAStyleTemplet = "<a href=\"{0}\">{1}</a>";
        private const string SiteMapPathSelectStyleTemplet = "<span class=\"{0}\">{1}</span>";
        private const string SiteMapPathSpanStyleTemplet = "&nbsp;<span>&gt;&gt;</span>&nbsp;";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (MapPathList == null) MapPathList = new List<MapPath>();
                for (int i = 0; i < MapPathList.Count(); i++)
                {
                    if (i == MapPathList.Count() - 1)
                    {
                        divSiteMapPath.InnerHtml += string.Format(SiteMapPathSelectStyleTemplet, "select", MapPathList[i].Text);
                    }
                    else
                    {
                        divSiteMapPath.InnerHtml += string.Format(SiteMapPathAStyleTemplet + SiteMapPathSpanStyleTemplet, MapPathList[i].Url, MapPathList[i].Text, "parent");
                    }
                }
            }
        }
    }
}

namespace VK.Casemeet.Web.Admin
{
    public class MapPath
    {
        public string Text { set; get; }
        public string Url { set; get; }
    }
}